package com.bjc.core.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bjc.base.core.BaseServiceImpl;
import com.bjc.base.core.IBaseDao;
import com.bjc.core.bean.request.RichTextReqVO;
import com.bjc.core.bean.response.RichTextVO;
import com.bjc.core.dao.IRichTextDao;
import com.bjc.core.service.IRichTextService;

/**
 * 富文本
 * @author 许自辉
 * @date 2017年8月31日
 */
@Service
public class RichTextImpl extends BaseServiceImpl<RichTextReqVO, RichTextVO> implements IRichTextService {

	private IRichTextDao richTextDao;

	@Autowired
	@Override
	public void setBaseDao(IBaseDao<RichTextReqVO, RichTextVO> baseDao) {
		this.baseDao = baseDao;
		this.richTextDao = (IRichTextDao) baseDao;
	}

	@Override
	public int insert(RichTextReqVO record) {
		RichTextReqVO reqVO = new RichTextReqVO();
		reqVO.setCode(record.getCode());
		RichTextVO reLookup = richTextDao.get(reqVO);
		if (null == reLookup) {
			return richTextDao.insert(record);
		} else {
			return -1;
		}
	}
}
